package org.codefinger.json.parser.deserializer;

import java.util.Collection;

import org.codefinger.json.parser.JSONArrayDeserializer;
import org.codefinger.json.parser.JSONDeserializer;
import org.codefinger.json.parser.JSONLexer;
import org.codefinger.json.parser.JSONObjectDeserializer;

public class ArrayDeserializerForCollection implements JSONArrayDeserializer {

	private Collection<Object>	collection;

	private JSONDeserializer	deserializer;

	public ArrayDeserializerForCollection(Collection<Object> collection,
			JSONDeserializer deserializer) {
		super();
		this.collection = collection;
		this.deserializer = deserializer;
	}

	@Override
	public JSONArrayDeserializer createArrayDeserializer() {
		return deserializer.createArrayDeserializer();
	}

	@Override
	public JSONObjectDeserializer createObjectDeserializer() {
		return deserializer.createObjectDeserializer();
	}

	@Override
	public void addValue(Object value) {
		collection.add(value);
	}

	@Override
	public void addStringValue(JSONLexer jsonLexer) {
		collection.add(deserializer.stringValue(jsonLexer));
	}

	@Override
	public void addIntValue(String value) {
		collection.add(deserializer.intValue(value));
	}

	@Override
	public void addFloatValue(String value) {
		collection.add(deserializer.floatValue(value));
	}

	@Override
	public void addFalseValue() {
		collection.add(deserializer.falseValue());
	}

	@Override
	public void addTrueValue() {
		collection.add(deserializer.trueValue());
	}

	@Override
	public void addNullValue() {
		collection.add(null);
	}

	
	@Override
	public Object getDeserializedValue() {
		return  collection;
	}

}
